<head>
    <meta charset="UTF-8">
<title>算法提高 Substrings</title>
<link rel="stylesheet" href="../css/main.css">
</head>
 <p class="pst">Description</p>
<div lang="en-US" class="ptx">You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found as a substring of any of the given strings.</div>
<p class="pst">Input</p>
<div lang="en-US" class="ptx">The first line of the input contains a single integer t (1 &lt;= t &lt;= 10), the number of test cases, followed by the input data for each test case. The first line of each test case contains a single integer n (1 &lt;= n &lt;= 100), the number of given strings, followed by n lines, each representing one string of minimum length 1 and maximum length 100. There is no extra white space before and after a string.</div>
<p class="pst">Output</p>
<div lang="en-US" class="ptx">There should be one line per test case containing the length of the largest string found.</div>
<p class="pst">Sample Input</p>
<p class="pst">2<br />
3<br />
ABCD<br />
BCDFF<br />
BRCD<br />
2<br />
rose<br />
orchid<br />
Sample Output</p>
<p class="pst">2<br />
2 <br />
&nbsp;</p>
<p class="pst">Source</p>
<div lang="en-US" class="ptx"><a href="http://poj.org/searchproblem?field=source&amp;key=Tehran+2002+Preliminary">Tehran 2002 Preliminary</a></div>